</div>
</div>
    <!-- jQuery -->
    <script src="__PUBLIC__/bower_components/jquery/dist/jquery.min.js"></script>
    <script>
        var rootUrl = '__ROOT__';
        var new_order_num = 0;
        var common_dom = '<li class="divider"></li><li><a onclick="toOrder()">查看全部</a></li>';
        $(document).ready(function() {
            connect();
        });
        
        //连接服务端
        function connect(){
            //创建websocket
            ws = new WebSocket("wss://" + document.domain + ":8283");

            //当socket连接打开时，输入用户名
            ws.onopen = function(){
                //登录
                if('{$Think.session.admin.type}' == '0'){
                    var repository_id = ('{$Think.session.admin.a_repository_id}'=='0'?'':'{$Think.session.admin.a_repository_id}')+'_'+('{$Think.session.admin.b_repository_id}'=='0'?'':'{$Think.session.admin.b_repository_id}');
                    //console.log("websocket握手成功，发送登录数据:" + repository_id);
                    ws.send('{"type":"join","group":"' + repository_id + '"}');
                }
            };
            //当有消息时根据消息类型显示不同信息
            ws.onmessage = function (e) {
                try{
                    var data = eval("(" + e.data + ")");
                    if (data.type == 'new_order') {
                        document.getElementById('msg').play();
                        //显示消息详情
                        var old_message = $('#new_order_detail').html();
                        var message = '<li><a href="#">'+data.message+'</a></li>'+old_message;
                        $('#new_order_detail').html(message);
                        //显示新增订单数量
                        new_order_num++;
                        $('#new_order_num').html(new_order_num);

                        console.log(data.message);
                    }
                }catch (ex){
                    console.log(!!e.data ? e.data : "");
                }
            };
            ws.onclose = function () {
                console.log("连接关闭，定时重连");
                connect();
            };
            ws.onerror = function () {
                console.log("出现错误");
            };
        }

        function toOrder(){
            new_order_num = 0;
            window.location.href = '{:U("Admin/Order/orderList/")}';
        }
    </script>
    <!-- /#wrapper -->

    <!-- Bootstrap Core JavaScript -->
    <script src="__PUBLIC__/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="__PUBLIC__/bower_components/jquery-form/jquery.form.js"></script>
    <script src="__PUBLIC__/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
    <script src="__PUBLIC__/bower_components/datatables/media/js/dataTables.bootstrap.min.js"></script>
    <script src="__PUBLIC__/dist/js/input.js"></script>
    
    <script type="text/javascript" src="__PUBLIC__/bower_components/zTree_v3/js/jquery.ztree.core-3.5.js"></script>

    <script type="text/javascript" src="__PUBLIC__/bower_components/plupload/js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/bower_components/plupload/js/plupload.full.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/bower_components/plupload/js/jquery.ui.plupload.js"></script>
    <script type="text/javascript" src="__PUBLIC__/bower_components/plupload/js/zh_CN.js"></script>
    <script src="__PUBLIC__/bower_components/datetimepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="__PUBLIC__/bower_components/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script type="text/javascript" src="__PUBLIC__/dist/js/common.js"></script>
    <script type="text/javascript" src="__PUBLIC__/dist/js/jquery-migrate-1.1.0.js"></script>
    <script type="text/javascript" src="__PUBLIC__/dist/js/jquery.jqprint-0.3.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="__PUBLIC__/bower_components/metisMenu/dist/metisMenu.min.js"></script>

    <!-- Morris Charts JavaScript -->
    <script src="__PUBLIC__/bower_components/raphael/raphael-min.js"></script>
    <!--script src="__PUBLIC__/bower_components/morrisjs/morris.min.js"></script-->
    <!--script src="__PUBLIC__/js/morris-data.js"></script-->

    <!-- Custom Theme JavaScript -->
    <script src="__PUBLIC__/dist/js/sb-admin-2.js"></script>
    <audio id="msg" src="__PUBLIC__/dist/audio/msg.mp3"></audio>
</body>

</html>